package creative.fire.interview.technicolor;

public class Comparing {
	public static void main(String[] args) {
		String s1 = "1";
		String s2 = "1";
		compare(s1, s2);
        s1+="1";
        s2+="1";
        compare(s1, s2);

        s1="1"+"1";
        s2="1"+"1";
        compare(s1, s2);

		String s3 = new String("11");
		String s4 = new String("11");
		compare(s3, s4);

		Integer i1 = new Integer(1);
		Integer i2 = new Integer(1);
		Integer i3 = Integer.valueOf(1);
		Integer i4 = Integer.valueOf(1);
        Integer i5 = Integer.valueOf(128);
        Integer i6 = Integer.valueOf(128);
		compare(i1, i2);
		compare(i3, i4);
		compare(i5, i6);
	}

	private static void compare(String c1, String c2) {
		int h1 = c1.hashCode();
		int h2 = c2.hashCode();
		System.out.print(h1 + "\t");
		System.out.print(h2 + "\t");
		System.out.println(c1 == c2);
	}

	private static void compare(Integer c1, Integer c2) {
		int h1 = c1.hashCode();
		int h2 = c2.hashCode();
		System.out.print(h1 + "\t");
		System.out.print(h2 + "\t");
		System.out.println(c1 == c2);
	}
}